<template>
  <div id="app">
    <!-- router-link -->
    <router-link to="/home" tag="button" replace>首页</router-link>
    <router-link to="/about" tag="button" replace>关于</router-link>
    <router-link :to="'/user/'+ userid" tag="button" replace>用户</router-link>
    <router-link :to="{path: '/profile', query: {name:'zhangsan',age:24,height:1.98}}" tag="button" replace>档案</router-link>
    <!-- <button @click="homeClick">首页</button>
    <button @click="aboutClick">关于</button> -->
    <keep-alive exclude="Profile">
      <router-view></router-view>
    </keep-alive>
  </div>
</template>

<script>
export default {
  name: 'App',
  data() {
    return {
      userid: 'zhangsan'
    }
  },
  methods: {
    homeClick(){
      // 通过代码的方式修改路由vue-router
      this.$router.push('home').catch(err=>{})
      console.log('homeClick');
    },
    aboutClick(){
      this.$router.push('about').catch(err=>{})
      console.log('aboutClick');
    }
  }
}
</script>

<style>
  .router-link-active{
    color: rgb(137, 126, 206);
  }
</style>
